<extend name="Base/common" />
<block name="body">
  <style type="text/css">
  td{ font-size:14px;}
  .data-top .btn{margin-bottom: 10px;}
  .data-top #title{width: 200px;}
  .data-top label{font-size: 16px;content: #666;font-weight: bold;}
  #phone{ position:relative; margin:0 0; width:400px; height:698px; background:url(__PUBLIC__/Home/images/preview_phone_short.jpg) no-repeat center 0;}
  #frame{ position:absolute; left:0; margin:100px 0 0 40px; width:320px; border:2px solid #333; background:#666; height:487px;width:320px; overflow:hidden;}
  .wx_menu{ position:absolute; bottom:0; left:0; right:0; height:50px; background:#fff;}
  .wx_menu .keyboard{ float:left; width:44px;height:50px; background:url(__IMG__/wx_menu_keyboard_icon.png) no-repeat; background-size:100% 100%; border-right:1px solid #CCC;}
  .wx_menu .menu{ display:-webkit-box; height:50px; float:left; width:275px;}
  .wx_menu .menu>div{ -webkit-box-flex:1; display:block; line-height:50px; color:#434343; text-align:center; border-right:1px solid #ccc; position:relative;}
  .wx_menu .menu>div:last-child{ border:none;}
  .wx_menu .menu>div img{ width:12px; vertical-align:-1px; margin-right:2px;}
  .wx_menu .sub_menu{ position:absolute; bottom:-358px; margin-left:0; padding:0 5px; border:1px solid #ccc; border-radius:5px; background:#fff; text-align:center; z-index:10;}
  .m_a_i{ position:relative; z-index:100; background:#fff;}
  .wx_menu .sub_menu a{ display:block; color:#434343; border-bottom:1px solid #ddd; height:40px; line-height:40px; padding:0 5px; white-space:nowrap}
  .wx_menu .sub_menu a:last-child{ border:none;}
  .wx_menu .sub_menu em{ position:absolute; width:10px; height:8px; bottom:-7px; left:50%; margin-left:-5px; background:url(__IMG__/arrow_down.png) no-repeat center bottom;}
  </style>
  <div class="span9 page_message">
    <section id="contents"> 
      <include file="Addons/_nav" />     
      <div class="table-bar" style=" display:none">
        <div class="fl">
          <empty name="model.extend">
           <div class="tools">
             <if condition="$add_button"><php> $add_url || $add_url = U('special_add?model='.$model['id']);</php><a class="btn" href="{$add_url}">新 增</a></if>
             <if condition="$del_button"><php> $del_url || $del_url = U('special_del?model='.$model['id']);</php><button class="btn ajax-post confirm" target-form="ids" url="{$del_url}">删 除</button></if>  
                <php> $send_url = U('send_menu?model='.$model['id']);</php><button class="btn ajax-post confirm" target-form="ids" url="{$send_url}">生成微信自定义菜单</button>              
           </div>
          </empty>
        </div>
        <!-- 高级搜索 -->
        <if condition="$search_button">
        <div class="search-form fr cf">
          <div class="sleft">
            <php> $search_url || $search_url = addons_url($_REQUEST ['_addons'].'://'.$_REQUEST ['_controller'].'/special_lists',array('model'=>$model['name']));</php>
            <php>empty($search_key) && $search_key=$model['search_key'];empty($search_key) && $search_key='title';</php>
            <input type="text" name="{$search_key}" class="search-input" value="{:I($search_key)}" placeholder="请输入关键字">
            <a class="sch-btn" href="javascript:;" id="search" url="{$search_url}"><i class="btn-search"></i></a> </div>
        </div>
        </if>
      </div>
         
      <!-- 数据列表 -->
      <div class="data-table" style="margin-top:40px; overflow:hidden">
        <div class="" style="float:left;">
          <div id="phone">
              <div id="frame">
                  <div class="wx_menu">
                      <span class="keyboard"></span>
                        <div class="menu">
                           <volist name="list_data" id="data">
                                 <eq name="data[pid]" value="0">
                                    <div class="m_a"  href="javascript:;">
                                      <div class="m_a_i">
                                          <img src="__IMG__/wx_menu_list_icon.png"/>{$data.title}
                                        </div>
                                        <div class="sub_menu">
                                          <div class="sub_menu_inner">
                                          <volist name="list_data" id="data1">
                                               <if condition="$data1['pid'] eq $data['id']">
                                                <a href="#">{$data1.title}</a>
                                                 </if>
                                            </volist>
                                            </div>
                                            <em></em>
                                        </div>
                                    </div>
                                 </eq>
                             </volist>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="table-striped" style="float:right; width:540px">
          <div class="data-top">
          <php> $post_url || $post_url = U('update');</php>
          <form id="form" action="{$post_url}" method="post" class="form-horizontal form-center">
              <label>状态：</label>
              <span>{$menu_info.show|get_menu_isshow}</span>&nbsp;&nbsp;&nbsp;
              <input type="text" name="menu_id" class="text hidden" id="menu_id" value="{$menu_info.id}">
              <input type="text" name="type" class="text hidden" id="title" value="{$menu_info.type}">
              <input type="text" name="title" class="text input-small" id="title" placeholder="输入菜单标题" value="{$menu_info.title}">
              <input class="btn  ajax-post" id="submit" type="submit" target-form="form-horizontal" value="修改" />
          </form>
      </div>

          <table cellpadding="0" cellspacing="1">
            <!-- 表头 -->
            <thead>
              <tr>
                  <th><a href="{:U('add',array('menu_id'=>$menu_info['id']))}">+添加</a></th>
                    <th>操作</th>
              </tr>
            </thead>
            
            <!-- 列表 -->
            <tbody>
              <volist name="list_data" id="data">
                <tr>
                  <!--
                  <volist name="list_grids" id="grid">
                    <td>{:get_list_field($data,$grid,$model)}</td>
                  </volist>
                  -->
                  <td>
                    <input class="ids" type="hidden" value="{$data.id}" name="ids[]">
                    <eq name="data[pid]" value="0">
                      <strong>{$data.title}</strong>
                     <else/>
                      &nbsp;&nbsp;&nbsp;&nbsp; ◆ {$data.title}
                     </eq>
                  </td>
                  <td>
                      <a href="{:U('edit',array('menu_id'=>$menu_info['id'] , 'id'=>$data[id]))}">编辑</a>
                      <a href="{:U('del',array('id'=>$data[id]))}">删除</a>
                  </td>
                </tr>
              </volist>
            </tbody>
          </table>
           
        </div>
      </div>
       <div class="form-item form_bh" style="margin:20px;">
          <button style="padding:12px 40px;" class="btn ajax-post confirm" type="button" target-form="ids" url="{:addons_url('CustomMenu://CustomMenu/send_menu',array('menu_id'=>$menu_info['id'] , 'model'=>$model['name']))}">{$submit_name|default='发布'}</button>
        </div>
      <div class="page"> {$_page|default=''} </div>
    </section>
  </div>
</block>
<block name="script"> 
  <script type="text/javascript">
$(function(){

  //搜索功能
  $("#search").click(function(){
    var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
    window.location.href = url;
  });

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });
  
  //初始化菜单样式
  $('.m_a').each(function(index, element) {
       var submenu = $(element).find('.sub_menu');
     if(submenu.find('a').html()==undefined){
      $(element).find('img').hide();
      submenu.hide();
     }else{
       var mW = $(element).width();
       var sW = submenu.width()+10+2;
       submenu.css('margin-left',(mW-sW)/2);
     }
    });
  $('.m_a').hover(function(){
    $(this).find('.sub_menu').animate({'bottom':58},300);
  },function(){
    $(this).find('.sub_menu').animate({'bottom':-458},300);
  })

})
</script> 
</block>